package com.bw.mallshop.mvvm.viewmodel;

import android.text.TextUtils;

import com.bw.common.entity.BaseEntity;
import com.bw.common.mvvm.viewmodel.BaseViewModel;
import com.bw.mallshop.entity.SecKillEntity;
import com.bw.mallshop.mvvm.model.SKillValueModel;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class SKillValueViewModel extends BaseViewModel<SKillValueModel> {

    public SecKillEntity.Value bean;

    @Override
    protected void initData() {

    }

    public void requestSkill(long time){
        //发起秒杀操作
        Map<String,Object> map = new HashMap<>();
        map.put("goodsCount",1);
        map.put("goodsDesc",bean.goods_desc);
        map.put("goodsIcon",bean.goods_default_icon);
        map.put("goodsId",bean.id);
        map.put("goodsPrice",Float.valueOf(TextUtils.isEmpty(bean.goods_default_price)
                ?"0":bean.goods_default_price)*1);
        map.put("goodsSku",bean.goods_default_sku);
        map.put("time",time);
        map.put("userId",1);
        m.requestSKill(map).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(this);
    }

    //分享方法
    public void share(){

    }

    //购物车列表
    public void carList(){

    }

    //加入购物车
    public void addCar(){

    }

    //返回方法
    public void finish(){
        finishPage();
    }

    @Override
    protected void result(BaseEntity entity) {

    }
}
